import os
import sys

# 请在此输入您的代码



import datetime
s = input()
date_list = list(map(int,[s[:4],s[4:6],s[-2:]]))
start = datetime.date(*date_list)
# print(start.year,start.month,start.day)
first = True
while True:
  start += datetime.timedelta(days=1)
  date_data = "{}{:0>2d}{:0>2d}".format(start.year,start.month,start.day)
  # print(date_data)
  if date_data == date_data[::-1]:
    if first:
      first = False
      print(date_data)
    if date_data[0] == date_data[2] == date_data[5] == date_data[-1] and date_data[1] == date_data[3] == date_data[4] == date_data[-2]:
      print(date_data)
      break
